import 'package:shining_red_star/model/unique.dart';

class ColorGroup implements Unique {
  @override
  final String id;
  final String title;

  const ColorGroup({
    required this.id,
    required this.title,
  });

  factory ColorGroup.fromJson(Map<String, dynamic> json) {
    return ColorGroup(
      id: json['id'],
      title: json['title'],
    );
  }

  static List<ColorGroup> jsonToList(List<dynamic> json) {
    return json.map((item) => ColorGroup.fromJson(item)).toList();
  }
}

class ColorInfo implements Unique {
  @override
  final String id;
  final String value;
  final String color;
  final String pinYin;
  final String aud;
  final List<String> group;

  const ColorInfo({
    required this.id,
    required this.value,
    required this.color,
    required this.pinYin,
    required this.aud,
    required this.group,
  });

  factory ColorInfo.fromJson(Map<String, dynamic> json) {
    return ColorInfo(
      id: json['id'],
      value: json['value'],
      color: json['color'],
      pinYin: json['pinYin'],
      aud: json['aud'],
      group: List.from(json['group']),
    );
  }

  static List<ColorInfo> jsonToList(List<dynamic> json) {
    return json.map((item) => ColorInfo.fromJson(item)).toList();
  }
}

class FixedColorGroup extends ColorGroup {
  final List<ColorInfo> colorList;

  const FixedColorGroup(
      {required this.colorList, required super.id, required super.title});
}